<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    // 构造函数的工厂模式：原料，加工，出厂
    function createPerson(name,qq){  // 构造函数
      var obj = new Object(); // 原料
      obj.name = name; // 加工
      obj.qq = qq;
      obj.showName = function(){
        alert("我的名字叫"+this.name);
      }
      obj.showQQ = function(){
        alert("我的qq号是"+this.qq)
      }
      return obj; // 出厂
    }
    var obj1 = createPerson("张三",456789);
    console.log(obj1.name)
    console.log(obj1.qq)

    var obj2 = createPerson("李四",789456);
    console.log(obj2.name);
    console.log(obj2.qq);
  </script>
</body>
</html>